from django.urls import path, include
from rest_framework.routers import DefaultRouter

from . import views
from .views import CustomAuthToken, BillViewSet, PropertyViewSet, RepairViewSet, StaffViewSet, UserRelationViewSet

#测试冲突
"""
URL 配置说明:
    - GET /community/tasknotices/ 获取所有任务通知
    - POST /community/tasknotices/ 新建任务通知
    - GET /community/notices/<pk> 获取单个通知
    - PUT /community/notices/<pk> 更新通知
    - DELETE /community/notices/<pk> 删除通知
    
    - GET /community/actives/ 获取所有活动
    - POST /community/actives/ 创建新活动
    - GET /community/actives/<pk> 获取单个活动
    - PUT /community/actives/<pk> 更新活动
    - DELETE /community/actives/<pk> 删除活动
    - GET /community/actives/category/<category> 按分类获取活动
    - GET /community/actives/user/<user_id> 获取用户的所有活动
    
    - GET /community/bgpics/ 获取所有背景图片
    
    - GET /community/bills/ 获取所有账单
    - POST /community/bills/ 创建新账单
    - GET /community/bills/<pk> 获取单个账单
    - PUT /community/bills/<pk> 更新账单
    - DELETE /community/bills/<pk> 删除账单
    - GET /community/bills/user/<user_id> 获取用户的所有账单
    - GET /community/bills/category/<category> 按类别获取账单
    - GET /community/bills/paid/<paid> 按支付状态获取账单
    
    - GET /community/comments/ 获取所有评论
    - POST /community/comments/ 创建新评论
    - GET /community/comments/<pk> 获取单个评论
    - PUT /community/comments/<pk> 更新评论
    - DELETE /community/comments/<pk> 删除评论
    - GET /community/comments/active/<active_id> 获取活动的所有评论
    - GET /community/comments/user/<user_id> 获取用户的所有评论
    
    - GET /community/enotices/ 获取所有紧急通知
    - POST /community/enotices/ 创建新紧急通知
    - GET /community/enotices/<pk> 获取单个紧急通知
    - PUT /community/enotices/<pk> 更新紧急通知
    - DELETE /community/enotices/<pk> 删除紧急通知
    
    - GET /community/lostfounds/ 获取所有失物招领
    - POST /community/lostfounds/ 创建新失物招领
    - GET /community/lostfounds/<pk> 获取单个失物招领
    - PUT /community/lostfounds/<pk> 更新失物招领
    - DELETE /community/lostfounds/<pk> 删除失物招领
    - GET /community/lostfounds/category/<category> 按类别获取失物招领
    
    - GET /community/users/ 获取所有用户
    - POST /community/users/ 创建新用户
    - GET /community/users/<pk> 获取单个用户
    - PUT /community/users/<pk> 更新用户
    - DELETE /community/users/<pk> 删除用户
    - POST /community/users/login/ 用户登录
    
    - GET /community/properties/ 获取所有房产
    - POST /community/properties/ 创建新房产
    - GET /community/properties/<pk> 获取单个房产
    - PUT /community/properties/<pk> 更新房产
    - DELETE /community/properties/<pk> 删除房产
    - GET /community/properties/user/<user_id> 获取用户的所有房产
    
    - GET /community/repairs/ 获取所有报修
    - POST /community/repairs/ 创建新报修
    - GET /community/repairs/<pk> 获取单个报修
    - PUT /community/repairs/<pk> 更新报修
    - DELETE /community/repairs/<pk> 删除报修
    - GET /community/repairs/user/<user_id> 获取用户的所有报修
    - GET /community/repairs/status/<status_value> 按状态获取报修
    
    - GET /community/staffs/ 获取所有员工
    - POST /community/staffs/ 创建新员工
    - GET /community/staffs/<pk> 获取单个员工
    - PUT /community/staffs/<pk> 更新员工
    - DELETE /community/staffs/<pk> 删除员工
"""
router = DefaultRouter()
router.register(r'bills', BillViewSet)
router.register(r'property', PropertyViewSet)
router.register(r'repair', RepairViewSet)

router.register(r'staffs', StaffViewSet)

router.register(r'userRelation', UserRelationViewSet)

urlpatterns = [
    # 通知相关 单挑单条记录操作

    path('notices/<int:pk>/', views.notice_detail, name='notices-detail'),

    path('enotices/<int:pk>/', views.enotice_detail, name='enotice-detail'),


    #todo  待整理
    
    # 活动相关路由 category=aaaa&title=aaaa
    path('actives/', views.active_list, name='active-list'),
    path('actives/<int:pk>/', views.active_detail, name='active-detail'),
    path('actives/category/<str:category>/', views.active_by_category, name='active-by-category'),
    path('actives/user/<int:user_id>/', views.active_by_user, name='active-by-user'),
    

    
    # 评论相关路由
    path('comments/', views.comment_list, name='comment-list'),

    path('comments/<int:pk>/', views.comment_detail, name='comment-detail'),



    #获取某个活动所有评论
    path('comments/active/<int:active_id>/', views.active_comments, name='active-comments'),
    

        # 活动报名相关路由
    path('activity-registrations/', views.activity_registration_list, name='activity-registration-list'),
    path('activity-registrations/<int:pk>/', views.activity_registration_detail, name='activity-registration-detail'),
    path('activity-registrations/user/<int:user_id>/', views.user_registrations, name='user-registrations'),
    path('activity-registrations/activity/<int:activity_id>/', views.activity_registrations, name='activity-registrations'),



    # 背景图片相关路由
    path('bgpics/', views.bgpic_list, name='bgpic-list'),

    path('bgpics/<int:pk>/', views.bgpic_detail, name='bgpic-detail'),

    path('notices/', views.notice_list_create, name='notices-list-create'),

    path('notices/<int:pk>/', views.notice_detail, name='notice-detail'),


    # 紧急通知相关路由
    path('enotices/', views.enotice_list, name='enotice-list'),

    path('enotices/<int:pk>', views.enotice_detail, name='staff-list'),
    # 用户相关路由
    path('users/', views.user_list, name='user-list'),

    path('users/<int:pk>/', views.user_detail, name='user-detail'),

    # 获取搜索记录
    path('search-records/user/<int:user_id>/', views.search_record_by_user, name='search-record-by-user'),

    #获取用户物业信息
    path('property-relations/user/<int:user_id>/', views.user_relations, name='user-relations'),

    # 获取用户房产信息
    path('properties/user/<int:user_id>/', views.property_by_user, name='property-by-user'),

    # 用户登录
    path('users/login/', CustomAuthToken.as_view(), name='user-login'),


    # 获取用户报修记录
    path('repairs/user/<int:user_id>/', views.repair_by_user, name='repair-by-user'),

    # 获取用户账单
    path('bills/user/<int:user_id>/', views.bill_by_user, name='bill-by-user'),

    path('', include(router.urls)),
    #path('', include(router.urls)),
    #path('', include(router.urls)),
    # 获取失物招领  name=lostfound-list&....
    path('lostfounds/', views.lostfound_list, name='lostfound-list'),
    # 获取某个失物招领
    path('lostfounds/<int:pk>/', views.lostfound_detail, name='lostfound-detail'),

]